#include <iostream>
#include <vector>
#include "Listnode.h"

using namespace std;


//Listnode constructor
Listnode::Listnode(vector<int> G, int start, int end, int supp)
{
	graph = G;
	start_index = start;
	end_index = end;
	support = supp;
	
	//cout << "Listnode created\n";
}

Listnode::Listnode()
{

}

Listnode::~Listnode()
{
	//cout << "Listnode destroyed\n";
}

//Print a listnode
void Listnode::print_listnode()
{
	vector<int>::iterator it;
	cout<<"\n\n***************************\n";
	cout << "Graph : \n";
	for(it = graph.begin() ; it < graph.end(); it++)
	{	
		cout << *it << " ";
	}
	cout << "\n";
	cout << "Start : " << start_index << "\n";
	cout << "End : " << end_index << "\n";
	cout << "Support : " << support << "\n";
	cout<<"***************************\n";
	return;
}

//Get the graph at the listnode
vector<int> Listnode::get_graph()
{
	return (graph);
}

//Get the support of the Listnode
int Listnode::get_support()
{
	return(support);
}

//Update the end index of a PSE
void Listnode::update_end_index(int t)
{
	end_index = t;
	return;
}

//Update the support of a PSE
void Listnode::update_support(int s)
{
	support = s;
	return;
}

//Get the start index of the PSE
int Listnode::get_start()
{
	return start_index;
}

int Listnode::get_end()
{
	return end_index;
}

//Update the graph of the PSE
void Listnode::update_graph(vector<int> C)
{
	//erase the old graph
	vector<int>::iterator it;

	it = graph.begin();
	while(!graph.empty())
	{
		it = graph.erase(it);
	}
	
	//Put the new graph in
	for(it = C.begin() ; it < C.end() ; it++)
	{
		graph.push_back(*it);
	}
		
	return;
}

